import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/login',
      name: 'login',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('../views/LoginView.vue'),
    },
    {
      path: '/home',
      name: 'home',
      component:()=>import('../views/HomeView.vue'),
    },
    {
      path: '/',
      redirect: '/home',
    },
    {
      path: '/register',
      name: 'register',
      component: ()=>import('../views/RegisterView.vue'),
    },
    {
      path:'/search',
      name: 'search',
      component:()=>import('../views/SearchView.vue'),
    },
    {
      path: '/admin',
      name: 'admin',
      component:()=>import('../views/AdminView.vue'),
      redirect: '/admin/dashboard',
      children: [
        {
          path: '/admin/dashboard',
          name: 'admin-dashboard',
          component: () => import('../views/admin/DashboardView.vue')
        },
        {
          path: '/products/list',
          name: 'admin-products-list',
          component: () => import('../views/admin/ProductListView.vue')
        },
        {
          path: '/products/categories',
          name: 'admin-products-categories',
          component: () => import('../views/admin/ProductCategoryView.vue')
        },
        {
          path: '/products/types',
          name: 'admin-products-types',
          component: () => import('../views/admin/ProductTypesView.vue')
        },
        {
          path: '/orders/list',
          name: 'admin-orders-list',
          component: () => import('../views/admin/OrderListView.vue')
        },
        {
          path: '/orders/detail',
          name: 'admin-orders-detail',
          component: () => import('../views/admin/OrderDetailView.vue')
        },
        {
          path: '/users/list',
          name: 'admin-users-list',
          component: () => import('../views/admin/UserListView.vue')
        },

        {
          path: '/settings/profile',
          name: 'admin-settings-profile',
          component: () => import('../views/admin/ProfileView.vue')
        }
        
      ]
    },
    {
      path:'/reset/:username?',
      name:'reset',
      component:import('../views/ResetPasswordView.vue'),
    },
    {
      path: '/goods/detail/:id',
      name: 'GoodsDetail',
      component: () => import('@/views/GoodsDetailView.vue')
    },
    {
      path: '/cart',
      name: 'Cart',
      component: () => import('@/views/CartView.vue')
    },
    {
      path: '/order',
      name: 'Order',
      component: () => import('@/views/OrderView.vue')
    },{
      path: '/orders',
      name: 'Orders',
      component: () => import('@/views/OrdersView.vue')
    },{
      path: '/profile',
      name: 'Profile',
      component: () => import('@/views/ProfileUserView.vue')
    }
  ],
})

export default router
